package org.budo.alipay;

/**
 * @author limingwei
 */
public interface BudoAlipayClient {}

//package org.budo.beidou.web.controller;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletResponse;
//
//import org.budo.module.account.service.api.IConstantService;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.alipay.api.AlipayClient;
//import com.alipay.api.DefaultAlipayClient;
//import com.alipay.api.request.AlipayTradePagePayRequest;
//
///**
// * @author lmw
// */
//@Controller
//public class AlipayController {
//    private static final String ALIPAY_SERVER_URL = "ALIPAY_SERVER_URL";
//
//    private static final String ALIPAY_APP_ID = "ALIPAY_APP_ID";
//
//    private static final String ALIPAY_PRIVATE_KEY = "ALIPAY_PRIVATE_KEY";
//
//    private static final String BIZ_CONTENT = "{" //
//            + "    \"out_trade_no\":\"20150320010101001\"," //
//            + "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," //
//            + "    \"total_amount\":88.88," //
//            + "    \"subject\":\"Iphone6 16G\"," //
//            + "    \"body\":\"Iphone6 16G\"," //
//            + "    \"passback_params\":\"merchantBizType%3d3C%26merchantBizNo%3d2016010101111\"," //
//            + "    \"extend_params\":{" //
//            + "    \"sys_service_provider_id\":\"2088511833207846\"" //
//            + "    }" //
//            + "  }";
//
//    private static final String NOTIFY_URL = "http://domain.com/CallBack/notify_url.jsp";
//
//    private static final String RETURN_URL = "http://domain.com/CallBack/return_url.jsp";
//
//    private static final String UTF_8 = "UTF-8";
//
//    @Resource
//    IConstantService constantService;
//
//    @ResponseBody
//    @RequestMapping("AlipayTradePagePay")
//    public void alipay(HttpServletResponse response) throws Throwable {
//        String serverUrl = constantService.findValueByKey(ALIPAY_SERVER_URL);
//        String appId = constantService.findValueByKey(ALIPAY_APP_ID);
//        String privateKey = constantService.findValueByKey(ALIPAY_PRIVATE_KEY);
//
//        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey);
//
//        AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest(); // 创建API对应的request
//        alipayRequest.setReturnUrl(RETURN_URL);
//        alipayRequest.setNotifyUrl(NOTIFY_URL); // 在公共参数中设置回跳和通知地址
//        alipayRequest.setBizContent(BIZ_CONTENT); // 填充业务参数
//        String form = alipayClient.pageExecute(alipayRequest).getBody(); // 调用SDK生成表单
//
//        response.setContentType("text/html;charset=" + UTF_8);
//        response.getWriter().write(form); // 直接将完整的表单html输出到页面
//        response.getWriter().flush();
//        response.getWriter().close();
//    }
//}
